#include "widget.h"
#include "ui_widget.h"
#include <QGridLayout>
#include <QLineEdit>
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QGridLayout * layout = new QGridLayout();
    this->setLayout(layout);

    QLineEdit * lineEdit_name = new QLineEdit();
    QLineEdit * lineEdit_age = new QLineEdit();
    QLineEdit * lineEdit_phonenumber = new QLineEdit();
    lineEdit_name->setPlaceholderText("请输入姓名");
    lineEdit_age->setPlaceholderText("请输入年龄");
    lineEdit_phonenumber->setPlaceholderText("请输入电话号码");

    layout->addWidget(lineEdit_name,0,0);
    layout->addWidget(lineEdit_age,1,0);
    layout->addWidget(lineEdit_phonenumber,2,0);

    lineEdit_age->setFixedHeight(40);
    lineEdit_name->setFixedHeight(40);
    lineEdit_phonenumber->setFixedHeight(40);

    QHBoxLayout *hlayout = new QHBoxLayout();
    layout->addLayout(hlayout,3,0);

    QPushButton *button1 = new QPushButton("提交");
    QPushButton *button2 = new QPushButton("取消");

    QSpacerItem *spaceritem = new QSpacerItem(200,10);
    QSpacerItem *leftitem = new QSpacerItem(50,10);
    QSpacerItem *rightitem = new QSpacerItem(50,10);


    hlayout->addSpacerItem(leftitem);
    hlayout->addWidget(button1);
    hlayout->addSpacerItem(spaceritem);
    hlayout->addWidget(button2);
    hlayout->addSpacerItem(rightitem);

}

Widget::~Widget()
{
    delete ui;
}

